#!/bin/sh
### BEGIN INIT INFO
# Provides:          redmine
# Required-Start:    $local_fs $remote_fs $network $mysql $named
# Required-Stop:     $local_fs $remote_fs $network $mysql $named
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Redmine projects manager
# Description:       This file should be used to start and stop Redmine.
### END INIT INFO

[ -f /etc/default/rcS ] && . /etc/default/rcS
. /lib/lsb/init-functions

REDMINE_USER="redmine"

WEBSERVER="server_puma"
WORKER1="sidekiq_git_hosting"

case "$1" in
  start)
    su - $REDMINE_USER -c "${WEBSERVER}.sh start"
    su - $REDMINE_USER -c "${WORKER1}.sh start"
  ;;
  stop)
    su - $REDMINE_USER -c "${WEBSERVER}.sh stop"
    su - $REDMINE_USER -c "${WORKER1}.sh stop"
  ;;
  restart)
    su - $REDMINE_USER -c "${WEBSERVER}.sh restart"
    su - $REDMINE_USER -c "${WORKER1}.sh restart"
  ;;
  *)
    echo "Usage : /etc/init.d/redmine {start|stop|restart}"
  ;;
esac
